from django.core.management import setup_environ
import tigeralbum.settings
setup_environ(tigeralbum.settings)

import os
import random
from datetime import datetime, timedelta
from hashlib import sha1
from tigeralbum.main.models import Photo
from tigeralbum.util import thisdirpath

import sys
sys.path.append(thisdirpath('', tigeralbum.__file__))

yesterday = datetime.now() - timedelta(days=1)
for photo in Photo.objects.filter(dt_submitted__lte=yesterday, location_x=None, location_y=None):
    photo.delete()
print 'Cleanup: done!'
